package com.avantis.common.base;

import com.avantis.common.exception.ServiceProcessException;
import com.avantis.common.msg.YResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @ClassName BaseController
 * @Description TODO
 * @Author kirago
 * @Date 2018/11/26 19:37
 * @Version 1.0
 **/
public class BaseController {

	protected final Logger logger = LoggerFactory.getLogger(this.getClass());

	protected YResult restProcessor(ResultProcessor processor){
		YResult result = null;
		try{
			result = processor.process();
		}
		catch (ServiceProcessException e1){
			logger.error("ServiceProcess Error Log :"+e1.getLocalizedMessage(),e1);
			result = YResult.error(e1.getMessage());
		}
		catch (Exception e){
			logger.error("Error Log :"+e.getLocalizedMessage(),e);
			result = YResult.error("服务器出现异常");
		}

		return result;
	}
}

